package com.lykj.llw.box.adapter.home

import android.view.View
import android.widget.ImageView
import android.widget.TextView
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.lykj.lib_base.component.GlideApp
import com.lykj.llw.box.R
import com.lykj.llw.box.data.bean.response.HomeResponse

/**
 * ================================================
 * 首页最新游戏列表适配器
 * ================================================
 *
 * @author gosha
 * @date 2023/10/24-11:20
 */
class HomeNewAdapter :
    BaseQuickAdapter<HomeResponse.DataDTO.NewGameListDTO, BaseViewHolder>(R.layout.item_reuse_home_game) {
    override fun convert(holder: BaseViewHolder, item: HomeResponse.DataDTO.NewGameListDTO) {
        holder.setText(R.id.tv_game_name, "${item.gamename}")
        holder.setText(R.id.tv_label, "${item.collection} ${item.gametype} ${item.gameSize}")
        holder.setText(R.id.tv_summery, "${item.openTime}")

        GlideApp.with(context)
            .load(item.icon)
            .transition(DrawableTransitionOptions.withCrossFade())
            .into(holder.getView(R.id.iv_icon))


        holder.getView<ImageView>(R.id.iv_discount_count).visibility = View.GONE
        if (item.payRatio == 0.01) {
            holder.getView<TextView>(R.id.tv_discount_normal).visibility = View.VISIBLE
        } else {
            holder.getView<TextView>(R.id.tv_discount_normal).visibility = View.GONE
        }
    }
}